<template>
  <div class="section_common">
    <div class="main">
      <el-form ref="form" label-width="100px">
        <el-form-item label="所属仓库" required>
          <el-select v-model="area" size="mini" placeholder="请选择">
            <el-option label="上雪仓" value="2"></el-option>
            <el-option label="东莞仓" value="1"></el-option>
          </el-select>
        </el-form-item>
        <!--<el-form-item label="使用类型">
          <el-radio v-model="classification" label="个人">个人</el-radio>
          <el-radio v-model="classification" label="公共">公共</el-radio>
        </el-form-item>-->
        <el-form-item label="分类选择" required>
          <el-select v-model="type" size="mini" placeholder="请选择">
            <el-option label="办公用品" value="shenzhen"></el-option>
            <el-option label="固定资产" value="hefei"></el-option>
          </el-select>
        </el-form-item>
        <p>资产登记</p>
        <el-form-item label="物品名称" required>
          <el-input v-model="productname" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="物品规格" required>
          <el-input v-model="specification" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="数量" required>
          <el-input v-model="number" size="mini"></el-input>
        </el-form-item>
        <el-form-item label="备注">
          <el-input type="textarea" v-model="other" size="mini"></el-input>
        </el-form-item>

        <van-steps direction="vertical" :active="active" active-icon="checked" active-color="#38f">
          <!--<p style="font-size:16px;font-weight: 900;margin-bottom: -10px;">审批人</p>-->
          <van-step v-show="oneShow">
            <van-image v-for="(item,index) in oneLd" :key="index" :src="item.avatar" width="60" height="60" style="margin-right: 20px;margin-bottom: 20px">
              <p style="font-size: 10px ;justify-content: center">{{item.name}}</p>
            </van-image>
          </van-step>

        </van-steps>
        <van-dialog v-model="show" show-cancel-button :before-close="chargeBtn">
          <!-- 输入框 -->
          <van-field v-model="reason" rows="1" autosize label="驳回原因" type="textarea" placeholder="请输入驳回原因"/>
        </van-dialog>

        <el-form-item>
          <el-button id="isAgree" v-show="showtg" v-bind:disabled="isShow" type="primary" size="mini" @click="submitAgree">{{message}}</el-button>
          <el-button id="isNotAgree" v-show="showbh" v-bind:disabled="isShow" type="warning" size="mini" @click="submitNotAgree">{{message1}}</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
  import {Toast} from "vant";
export default {
  data() {
    return {
      id:"",
      area:"2",
      classification:"个人",
      type:"办公用品",
      productname:"",
      number:"",
      specification:"",
      other:"",

      nowUser:"",
      title: "资产登记",

      addAssetApply: '/mobiles/addAssetApply',
      oneShow:false,
      oneLd:[],

      isShow:false,
      message:"通过",
      message1:"驳回",
      show:false,
      reason:"",

      showtg:true,
      showbh:true,
      active:-1,

    };
  },
  created() {
    this.nowUser=JSON.parse(localStorage.getItem('userInfo')).userId;
    this.id= this.$route.params.id;
    this.getAddassetInfo();
  },
  methods: {
    getAddassetInfo(){
      this.$https.post('/mobiles/getAddassetInfo',{
        nowUser:this.nowUser,
        id:this.id
      }).then((res)=>{

        this.area=res.data.data.area;
        this.type=res.data.data.type;
        this.productname=res.data.data.productname;
        this.number=res.data.data.number;
        this.specification=res.data.data.specification;
        this.other=res.data.data.other;
        if (res.data.data.result=="已通过"){
          this.isShow=true;
          this.message="已通过";
          this.showbh=false;
        }else if (res.data.data.result=="已驳回"){
          this.isShow=true;
          this.message1="已驳回";
          this.showtg=false;
        }

      }).catch(err => {
        console.log(err);
      })
    },
    // 返回
    goBack() {
      this.$router.go(-1);
    },
    // 提交同意
    submitAgree() {
      this.show=false;
      this.$https.post('/mobiles/isAgreeAddasset', {
        nowUser:this.nowUser,
        id:this.id,
      }).then(() => {
        Toast("已通过");
        this.getAddassetInfo();//找到对应的页面详情，及领导信息
      }).catch(err => {
        console.log(err)
      });
    },
    //驳回
    submitNotAgree() {
      this.show=true;
    },
    chargeBtn(action,done){
      if (action==='cancel'){
        done();
      }else if (action==='confirm'){
        this.show=false;
        this.$https.post('/mobiles/isAgreeAddasset', {
          nowUser:this.nowUser,
          id:this.id,
          reason:this.reason,
        }).then(() => {
          Toast("已驳回");
          this.getAddassetInfo();//找到对应的页面详情，及领导信息
        }).catch(err => {
          console.log(err)
        });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.main {
  display: flex;
  justify-items: center;
  margin: 0 auto;
  .el-form {
    padding-right: 10px;
    .el-form-item {
      .el-form-item__label {
        line-height: 16px;
      }
      margin-bottom: 5px;
    }
  }
}
</style>